//svg矢量图对象
var svg;
//单线图数据
// var svgData;
// 变压器ID
var byqId;
// 变压器名称
var byqName;
//点位
var svgPoint;
//点位原始数据
var svgRawPoint;
//拉线
var svgLaxian;
//跨越物
var svgCross;
//单线图描述
var svgSpec;
//矢量图宽度
var svgWidth=1000;
//矢量图高度
var svgHeight=1000;
//经纬度放大倍数
var zoomNum=400000;
//标志矩形框的宽度
var svgRectWidth=340;
//标志矩形框的高度
var svgRectHeight=555;
//矩形框的误差值
var wuchaData=50;
//矢量图最小的宽度和高度
var minSvgWidth=1000;
var minSvgHeight=1000;
//设计单位
var textsjdw="单位名称";
//工程名称
var textgcmc="工程名称";
var projectName="项目名称";
var stageName="项目阶段";

//默认颜色
var default_color="RGB(128,128,128)";
//黑色
var black_color="RGB(0,0,0)";
//白色
var white_color="RGB(255,255,255)";
/**
 * svg初始化
 */
function svg_init(){
    svg.clear();
    svgWidth=svg.attr("width");
    svgHeight=svg.attr("height");
    //标尺外宽
    // var lineType=$("#explorationType").val();
    // if(lineType == 11){
    //     svg_new_init();
        svg_400_init();
    // }else{//拆旧
    //     svg_old_init()
    // }
}

function zhibei(svgWidth){
    //指北表标志
    svg.paper.text(svgWidth-34, 45, "N").attr({
        style:"font-size:10pt",fill:default_color
    });
    svg.paper.polygon([svgWidth-30,50,svgWidth-50,100,svgWidth-30,85]).attr(
        {
            fill:black_color,stroke:black_color
        }
    );

    svg.paper.line(svgWidth-30, 50, svgWidth-50,100).attr({
        stroke: black_color,
        strokeWidth: 1,
    });
    svg.paper.line(svgWidth-50, 100, svgWidth-30,85).attr({
        stroke: black_color,
        strokeWidth: 1,
    });
    svg.paper.line(svgWidth-30,85, svgWidth-10,100).attr({
        stroke: black_color,
        strokeWidth: 1,
    });
    svg.paper.line(svgWidth-10,100,svgWidth-30, 50).attr({
        stroke: black_color,
        strokeWidth: 1,
    });
}

/**
 *选择拆旧的时候的标尺
 */
function svg_old_init(){
    var x1= 40,x2=200,y=20,h=40,i=0;
    svg_rect(0,0,340,400,black_color);
    svg_old_transformer(x1,y+h*i,true);
    svg_old_pad_mounted(x2,y+h*i++,true);
    svg_old_poles(x1-5,y+h*i,true);
    svg_old_10kv_lines(x2-30,y+h*i,x2+30,y+h*i++,true);
    svg_old_38_lines(x1-30,y+h*i,x1+30,y+h*i,true);
    svg_old_22_lines(x2-30,y+h*i,x2+30,y+h*i++,true);

    svg_old_cable_wall(x1,y+h*i,true);
    svg_old_passageway_wall(x2,y+h*i++,true);
    //电缆
    svg_old_cable_well(x1,y+h*i,true);
    //特征点
    svg_crossing_thing(x2,y+h*i++,true,"跨越物");

    svg_catch_fire_point(x1,y+h*i,true);
    //拉线
    svg_pull_rule(x2,y+h*i++);

    svg_rect_center_text(x1,y+h*i,"户表箱","户表箱",true);
    svg_next_door(x2,y+h*i++,true,"下户名称","下户数","下户点")

    svg_rect_center_text(x1,y+h*i,"开关站","开关站",true);
    svg_rect_center_text(x2,y+h*i++,"配电室","配电室",true);

    svg_rect_center_text(x1,y+h*i,"分支箱","电缆分支箱",true);
    svg_rect_center_text(x2,y+h*i++,"环网柜","环网柜",true);


}

/**
 * 选择新建的时候标尺
 */
function svg_new_init(){
    var x1= 40,x2=200,y=20,h=40,i=0;
    svg_rect(0,0,340,595,black_color);
    //图例
    svg_tuli(0,30,340,595);i++;
    svg_old_transformer(x1,y+h*i,true);
    svg_new_transformer(x2,y+h*i++,true);
    svg_old_pad_mounted(x1,y+h*i,true);
    svg_new_pad_mounted(x2,y+h*i++,true);

    // svg_old_poles(x1-5,y+h*i,true);
    //  将原有杆塔换位同杆点位显示
    svg_tg_poles(x1-5,y+h*i,true);

    svg_new_poles(x2-5,y+h*i++,true);
    svg_old_10kv_lines(x1-30,y+h*i,x1+30,y+h*i,true);
    svg_new_10kv_lines(x2-30,y+h*i,x2+30,y+h*i++,true);

    //svg_new_38_lines(200,100,100,200,true);
    svg_old_38_lines(x1-30,y+h*i,x1+30,y+h*i,true);
    svg_new_38_lines(x2-30,y+h*i,x2+30,y+h*i++,true);

    svg_old_22_lines(x1-30,y+h*i,x1+30,y+h*i,true);
    svg_new_22_lines(x2-30,y+h*i,x2+30,y+h*i++,true);

    svg_old_cable_wall(x1,y+h*i,true);
    svg_new_cable_wall(x2,y+h*i++,true);

    svg_old_passageway_wall(x1,y+h*i,true);
    svg_new_passageway_wall(x2,y+h*i++,true);
    //电缆
    // svg_old_cable_well(x1,y+h*i,true);
    svg_crossing_thing(x1,y+h*i,true,"跨越物");
    svg_new_cable_well(x2,y+h*i++,true);

    svg_catch_fire_point(x1,y+h*i,true);
    //拉线
    svg_pull_rule(x2,y+h*i++);

    svg_rect_center_text(x1,y+h*i,"户表箱","户表箱",true);
    svg_next_door(x2,y+h*i++,true,"下户名称","下户数","下户点")

    svg_rect_center_text(x1,y+h*i,"开关站","开关站",true);
    svg_rect_center_text(x2,y+h*i++,"配电室","配电室",true);

    svg_rect_center_text(x1,y+h*i,"分支箱","电缆分支箱",true);
    svg_rect_center_text(x2,y+h*i++,"环网柜","环网柜",true);

    //  特征点
    // svg_crossing_thing(x1,y+h*i,true,"跨越物");
    //  同杆点位（文件用cad打开后出现位置偏移，考虑使用其他图形）
    // svg_new_point_one(x2,y+h*i++,true);
}

function svg_400_init(){
    var x1= 40,x2=200,y=20,h=40,i=0;
    svg_rect(0,0,310,250,black_color);                              //  外框
    svg_tuli(0,30,310,250);i++;                                      //  图例
    svg_new_transformer(x1,y+h*i++,true);                           //  变压器
    svg_tg_poles(x1-5,y+h*i,true);                                  //  同杆
    svg_new_poles(x2,y+h*i-h,true);                                 //  杆塔
    svg_new_38_lines(x2-30,y+h*i,x2+30,y+h*i++,true);               //  380v线路
    svg_new_22_lines(x2-30,y+h*i,x2+30,y+h*i++,true);               //  220v线路
    svg_pull_rule(x2,y+h*i-3);                                     //  拉线
    svg_crossing_thing(x1,y+h*i-h,true,"跨越物");                  //  跨越物
    svg_rect_center_text(x1,y+h*i++,"HB","户表箱",true);         //  表箱
    svg_rect_center_text(x2,y+h*i++,"XH","下户点",true);         //  下户点
    svg_rect_center_text(x1,y+h*i-h,"FZ","分支箱",true);         //  分支箱

    // svg_next_door(x2,h+y+h*i++,true,"下户名称","下户数","下户点")   //  下户点
    // svg_old_transformer(x1,y+h*i,true);
    // svg_old_pad_mounted(x1,y+h*i,true);
    // svg_new_pad_mounted(x2,y+h*i++,true);

    // svg_old_poles(x1-5,y+h*i,true);
    //  将原有杆塔换位同杆点位显示

    // svg_old_10kv_lines(x1-30,y+h*i,x1+30,y+h*i,true);
    // svg_new_10kv_lines(x2-30,y+h*i,x2+30,y+h*i++,true);

    //svg_new_38_lines(200,100,100,200,true);
    // svg_old_38_lines(x1-30,y+h*i,x1+30,y+h*i,true);

    // svg_old_22_lines(x1-30,y+h*i,x1+30,y+h*i,true);


    // svg_old_cable_wall(x1,y+h*i,true);
    // svg_new_cable_wall(x2,y+h*i++,true);
    //
    // svg_old_passageway_wall(x1,y+h*i,true);
    // svg_new_passageway_wall(x2,y+h*i++,true);
    //电缆
    // svg_old_cable_well(x1,y+h*i,true);

    // svg_new_cable_well(x2,y+h*i++,true);

    // svg_catch_fire_point(x1,y+h*i,true);
    //拉线

    // svg_rect_center_text(x1,y+h*i,"开关站","开关站",true);
    // svg_rect_center_text(x2,y+h*i++,"配电室","配电室",true);


    // svg_rect_center_text(x2,y+h*i++,"环网柜","环网柜",true);

    //  特征点
    // svg_crossing_thing(x1,y+h*i,true,"跨越物");
    //  同杆点位（文件用cad打开后出现位置偏移，考虑使用其他图形）
    // svg_new_point_one(x2,y+h*i++,true);
}


/**
 * 画矩形
 * xy  左上角坐标
 * width height 高度和宽度
 * color 边框颜色
 */
function svg_rect(x,y,width,height,color){
    svg.paper.rect(x, y, width, height, 0).attr({
        stroke:color,fill:"none"
    });
}

/**
 * 画图例
 */
function svg_tuli(x,y,width,height){
    svg.paper.line(x, y, x+width,y).attr({
        stroke: black_color,
        strokeWidth: 1,
    });

    svg.paper.text(x+width/3, y-8, "图").attr({
        style:"font-size:10pt",fill:default_color
    });
    svg.paper.text(x+width*2/3, y-8, "例").attr({
        style:"font-size:10pt",fill:default_color
    });
}

/**
 * 画原有变压器
 */
function svg_old_transformer(x,y,isSign){
    svg.paper.circle(x-5,y, 10).attr({
        fill:default_color,stroke:black_color
    });
    svg.paper.circle(x+5,y, 10).attr({
        fill:"none",stroke:black_color
    });
    if(isSign){
        svg.paper.text(x+30, y+5, "原有变压器").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 画新建变压器
 */
function svg_new_transformer(x,y,isSign){
    svg.paper.circle(x-5,y, 10).attr({
        fill:"none",stroke:black_color
    });
    svg.paper.circle(x+5,y, 10).attr({
        fill:"none",stroke:black_color
    });
    if(isSign){
        svg.paper.text(x+30, y+5, "变压器").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 原有箱式变压器
 */
function svg_old_pad_mounted(x,y,isSign){
    svg.paper.rect(x-23, y-15, 46, 30, 0).attr({
        stroke:black_color,fill:"none"
    });
    svg.paper.circle(x-5,y, 10).attr({
        fill:default_color,stroke:black_color
    });
    svg.paper.circle(x+5,y, 10).attr({
        fill:"none",stroke:black_color
    });
    if(isSign){
        svg.paper.text(x+30, y+5, "原有箱式变").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 新建箱式变压器
 */
function svg_new_pad_mounted(x,y,isSign){
    svg.paper.rect(x-23, y-15, 46, 30, 0).attr({
        stroke:black_color,fill:"none"
    });
    svg.paper.circle(x-5,y, 10).attr({
        fill:"none",stroke:black_color
    });
    svg.paper.circle(x+5,y, 10).attr({
        fill:"none",stroke:black_color
    });
    if(isSign){
        svg.paper.text(x+30, y+5, "新建箱式变").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 原有杆塔
 */
function svg_old_poles(x,y,isSign){
    svg.paper.circle(x,y, 10).attr({
        fill:default_color,stroke:black_color
    });
    if(isSign){
        svg.paper.text(x+30, y+5, "原有杆塔").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

function svg_tg_poles(x,y,isSign,height){
    svg.paper.circle(x,y, 10).attr({
        fill:"#DCDCDC",stroke:black_color
    });
    if(isSign){
        svg.paper.text(x+30, y+5, "同杆").attr({
            style:"font-size:10pt",fill:default_color
        });
    }else{
        // alertTip("b="+x+","+y);
        if(height!=undefined){
            if(height.length==1){
                svg.paper.text(x-4,y+5, height);
            }else{
                svg.paper.text(x+8,y+5, height);
            }
        }
    }


}


/**
 * 新建杆塔
 */
function svg_new_poles(x,y,isSign,height){

    svg.paper.circle(x,y, 10).attr({
        fill:white_color,stroke:black_color
    });
    if(isSign){
        // alertTip("a="+x+","+y);
        svg.paper.text(x+30, y+5, "杆塔").attr({
            style:"font-size:10pt",fill:default_color
        });
    }else{
        // alertTip("b="+x+","+y);
        if(height!=undefined){
            if(height.length==1){
                svg.paper.text(x-4,y+5, height);
            }else{
                svg.paper.text(x-8,y+5, height);
            }
        }
    }
}


/**
 * 原有10KV线路
 */
function svg_old_10kv_lines(x1,y1,x2,y2,isSign){
    //连接2点线
    svg.paper.line(x1, y1, x2,y2).attr({
        stroke: black_color,
        strokeWidth: 3,
        strokeDasharray:"5,5",
    });
    if(isSign && y1==y2){
        svg.paper.text(x2, y2+5, "原有10KV线路").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
    //横坐标相等
    if(y1==y2){
        var xx1=(x2+x1)/2;
        var hh1=10;
        svg.paper.line(xx1, y1-hh1, xx1,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1-5, y1-hh1, xx1-5,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1+5, y1-hh1, xx1+5,y2+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else if(x1==x2){//纵坐标相等
        var yy1=(y2+y1)/2;
        var hh1=10;
        svg.paper.line(x1-hh1, yy1, x1+hh1,yy1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1-5, x1+hh1,yy1-5).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1+5, x1+hh1,yy1+5).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else{
        var k = (y1-y2)/(x1-x2);
        var b=y1-k*x1;
        var k2=-1/k;
        var yy2=(y1+y2)/2;
        var xx2=(x1+x2)/2;
        var b2=yy2-k2*xx2;
        var hh1=20;
        var hh2=5;
        var points = getPointBykbAndDistance(k,b,hh2,xx2,yy2);
        drawLines1(k2,b2,hh1,xx2,yy2);
        var b3=points.y1-k2*points.x1;
        drawLines1(k2,b3,hh1,points.x1,points.y1);
        var b4=points.y2-k2*points.x2;
        drawLines1(k2,b4,hh1,points.x2,points.y2);

    }

}

/**
 * 新建10KV线路
 */
function svg_new_10kv_lines(x1,y1,x2,y2,isSign){
    //连接2点线
    svg.paper.line(x1, y1, x2,y2).attr({
        stroke: black_color,
        strokeWidth: 3,
    });
    if(isSign && y1==y2){
        svg.paper.text(x2, y2+5, "新建10KV线路").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
    //横坐标相等
    if(y1==y2){
        var xx1=(x2+x1)/2;
        var hh1=10;
        svg.paper.line(xx1, y1-hh1, xx1,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1-5, y1-hh1, xx1-5,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1+5, y1-hh1, xx1+5,y2+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else if(x1==x2){//纵坐标相等
        var yy1=(y2+y1)/2;
        var hh1=10;
        svg.paper.line(x1-hh1, yy1, x1+hh1,yy1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1-5, x1+hh1,yy1-5).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1+5, x1+hh1,yy1+5).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else{
        var k = (y1-y2)/(x1-x2);
        var b=y1-k*x1;
        var k2=-1/k;
        var yy2=(y1+y2)/2;
        var xx2=(x1+x2)/2;
        var b2=yy2-k2*xx2;
        var hh1=20;
        var hh2=5;
        var points = getPointBykbAndDistance(k,b,hh2,xx2,yy2);
        drawLines1(k2,b2,hh1,xx2,yy2);
        var b3=points.y1-k2*points.x1;
        drawLines1(k2,b3,hh1,points.x1,points.y1);
        var b4=points.y2-k2*points.x2;
        drawLines1(k2,b4,hh1,points.x2,points.y2);

    }

}


/**
 * 原有0.38KV线路
 */
function svg_old_38_lines(x1,y1,x2,y2,isSign){
    //连接2点线
    svg.paper.line(x1, y1, x2,y2).attr({
        stroke: black_color,
        strokeWidth: 2,
        strokeDasharray:"5,5",
    });
    if(isSign && y1==y2){
        svg.paper.text(x2, y2+5, "原有0.38KV线路").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
    //横坐标相等
    if(y1==y2){
        var xx1=(x2+x1)/2;
        var hh1=10;
        svg.paper.line(xx1, y1-hh1, xx1,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1-5, y1-hh1, xx1-5,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1+5, y1-hh1, xx1+5,y2+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1+10, y1-hh1, xx1+10,y2+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else if(x1==x2){//纵坐标相等
        var yy1=(y2+y1)/2;
        var hh1=10;
        svg.paper.line(x1-hh1, yy1, x1+hh1,yy1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1-5, x1+hh1,yy1-5).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1+5, x1+hh1,yy1+5).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1+10, x1+hh1,yy1+10).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else{
        var k = (y1-y2)/(x1-x2);
        var b=y1-k*x1;
        var k2=-1/k;
        var yy2=(y1+y2)/2;
        var xx2=(x1+x2)/2;
        var b2=yy2-k2*xx2;
        var hh1=20;
        var hh2=5;
        var points = getPointBykbAndDistance(k,b,hh2,xx2,yy2);
        //drawLines1(k2,b2,hh1,xx2,yy2);
        var b3=points.y1-k2*points.x1;
        drawLines1(k2,b3,hh1,points.x1,points.y1);
        var b4=points.y2-k2*points.x2;
        drawLines1(k2,b4,hh1,points.x2,points.y2);

        var points2 = getPointBykbAndDistance(k,b,hh2,points.x1,points.y1);

        var b5=points2.y1-k2*points2.x1;
        drawLines1(k2,b5,hh1,points2.x1,points2.y1);
        var b6=points2.y2-k2*points2.x2;
        drawLines1(k2,b6,hh1,points2.x2,points2.y2);

    }

}


/**
 * 新建0.38KV线路
 */
function svg_new_38_lines(x1,y1,x2,y2,isSign){
    //连接2点线
    svg.paper.line(x1, y1, x2,y2).attr({
        stroke: black_color,
        strokeWidth: 2,
    });
    if(isSign && y1==y2){
        svg.paper.text(x2, y2+5, "0.38KV线路").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
    //横坐标相等
    if(y1==y2){
        var xx1=(x2+x1)/2;
        var hh1=10;
        svg.paper.line(xx1, y1-hh1, xx1,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1-5, y1-hh1, xx1-5,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1+5, y1-hh1, xx1+5,y2+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1+10, y1-hh1, xx1+10,y2+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else if(x1==x2){//纵坐标相等
        var yy1=(y2+y1)/2;
        var hh1=10;
        svg.paper.line(x1-hh1, yy1, x1+hh1,yy1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1-5, x1+hh1,yy1-5).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1+5, x1+hh1,yy1+5).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1+10, x1+hh1,yy1+10).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else{
        var k = (y1-y2)/(x1-x2);
        var b=y1-k*x1;
        var k2=-1/k;
        var yy2=(y1+y2)/2;
        var xx2=(x1+x2)/2;
        var b2=yy2-k2*xx2;
        var hh1=20;
        var hh2=5;
        var points = getPointBykbAndDistance(k,b,hh2,xx2,yy2);
        //drawLines1(k2,b2,hh1,xx2,yy2);
        var b3=points.y1-k2*points.x1;
        drawLines1(k2,b3,hh1,points.x1,points.y1);
        var b4=points.y2-k2*points.x2;
        drawLines1(k2,b4,hh1,points.x2,points.y2);

        var points2 = getPointBykbAndDistance(k,b,hh2,points.x1,points.y1);

        var b5=points2.y1-k2*points2.x1;
        drawLines1(k2,b5,hh1,points2.x1,points2.y1);
        var b6=points2.y2-k2*points2.x2;
        drawLines1(k2,b6,hh1,points2.x2,points2.y2);

    }

}

/**
 * 原有0.22KV线路
 */
function svg_old_22_lines(x1,y1,x2,y2,isSign){
    //连接2点线
    svg.paper.line(x1, y1, x2,y2).attr({
        stroke: black_color,
        strokeWidth: 1,
        strokeDasharray:"5,5",
    });
    if(isSign && y1==y2){
        svg.paper.text(x2, y2+5, "原有0.22KV线路").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
    //横坐标相等
    if(y1==y2){
        var xx1=(x2+x1)/2;
        var hh1=10;
        svg.paper.line(xx1, y1-hh1, xx1,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1-5, y1-hh1, xx1-5,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else if(x1==x2){//纵坐标相等
        var yy1=(y2+y1)/2;
        var hh1=10;
        svg.paper.line(x1-hh1, yy1, x1+hh1,yy1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1-5, x1+hh1,yy1-5).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else{
        var k = (y1-y2)/(x1-x2);
        var b=y1-k*x1;
        var k2=-1/k;
        var yy2=(y1+y2)/2;
        var xx2=(x1+x2)/2;
        var b2=yy2-k2*xx2;
        var hh1=20;
        var hh2=5;
        var points = getPointBykbAndDistance(k,b,hh2,xx2,yy2);
        drawLines1(k2,b2,hh1,xx2,yy2);
        var b3=points.y1-k2*points.x1;
        drawLines1(k2,b3,hh1,points.x1,points.y1);

    }

}


/**
 * 新建0.22KV线路
 */
function svg_new_22_lines(x1,y1,x2,y2,isSign){
    //连接2点线
    svg.paper.line(x1, y1, x2,y2).attr({
        stroke: black_color,
        strokeWidth: 1,
    });
    if(isSign && y1==y2){
        svg.paper.text(x2, y2+5, "0.22KV线路").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
    //横坐标相等
    if(y1==y2){
        var xx1=(x2+x1)/2;
        var hh1=10;
        svg.paper.line(xx1, y1-hh1, xx1,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(xx1-5, y1-hh1, xx1-5,y1+hh1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else if(x1==x2){//纵坐标相等
        var yy1=(y2+y1)/2;
        var hh1=10;
        svg.paper.line(x1-hh1, yy1, x1+hh1,yy1).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
        svg.paper.line(x1-hh1, yy1-5, x1+hh1,yy1-5).attr({
            stroke: black_color,
            strokeWidth: 1,
        });
    }else{
        var k = (y1-y2)/(x1-x2);
        var b=y1-k*x1;
        var k2=-1/k;
        var yy2=(y1+y2)/2;
        var xx2=(x1+x2)/2;
        var b2=yy2-k2*xx2;
        var hh1=20;
        var hh2=5;
        var points = getPointBykbAndDistance(k,b,hh2,xx2,yy2);
        drawLines1(k2,b2,hh1,xx2,yy2);
        var b3=points.y1-k2*points.x1;
        drawLines1(k2,b3,hh1,points.x1,points.y1);

    }

}
/**
 * 已知k b 线段距离h 线段中心点坐标 画线段
 * (x1-x2)²+(y1-y2)²=h²
 * x1+x2=2*x0
 * y2=k*x2+b
 * y1=k*x1+b
 */
function drawLines1(k,b,h,x0,y0){
    x1=Math.sqrt(h*h/(4+4*k*k))+x0;
    y1=k*x1+b;
    x2=2*x0-x1;
    y2=k*x2+b;
    svg.paper.line(x1, y1, x2, y2).attr({
        stroke: black_color,
        strokeWidth: 1,
    });
}
/**
 *计算在一条直线上从某点开始到一定距离的下一个点
 * (x1-x0)²+(y1-y0)²=h²
 *  y1=k*x1+b
 */
function getPointBykbAndDistance(k,b,h,x0,y0){
    var a=1+k*k;
    var bb=2*k*(b-y0)-2*x0;
    var c=x0*x0+(b-y0)*(b-y0)-h*h;
    var x1=(-1*bb+Math.sqrt(bb*bb-4*a*c))/(2*a);
    var x2=(-1*bb-Math.sqrt(bb*bb-4*a*c))/(2*a);
    var y1=k*x1+b;
    var y2=k*x2+b;
    return {
        x1:x1,
        y1:y1,
        x2:x2,
        y2:y2
    }
}

/**
 * 原有沿墙电缆
 */
function svg_old_cable_wall(x,y,isSign){
    svg.paper.rect(x-30, y-5, 10, 10, 0).attr({
        stroke:black_color,fill:default_color
    });

    svg.paper.rect(x+20, y-5, 10, 10, 0).attr({
        stroke:black_color,fill:default_color
    });

    svg.paper.line(x-30,  y-5, x+20, y-5).attr({
        stroke:black_color,fill:default_color
    });

    if(isSign){
        svg.paper.text(x+30, y+5, "原有电缆(沿墙)").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 新建沿墙电缆
 */
function svg_new_cable_wall(x,y,isSign){
    svg.paper.rect(x-30, y-5, 10, 10, 0).attr({
        stroke:black_color,fill:"none"
    });

    svg.paper.rect(x+20, y-5, 10, 10, 0).attr({
        stroke:black_color,fill:"none"
    });

    svg.paper.line(x-30,  y-5, x+20, y-5).attr({
        stroke:black_color,fill:default_color
    });

    if(isSign){
        svg.paper.text(x+30, y+5, "新建电缆(沿墙)").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 原有通道电缆
 */
function svg_old_passageway_wall(x,y,isSign){
    svg.paper.rect(x-30, y-5, 10, 10, 0).attr({
        stroke:black_color,fill:default_color
    });

    svg.paper.rect(x+20, y-5, 10, 10, 0).attr({
        stroke:black_color,fill:default_color
    });

    svg.paper.line(x-30,  y-5, x+20, y-5).attr({
        stroke:black_color,fill:default_color
    });

    svg.paper.line(x-30,  y+5, x+20, y+5).attr({
        stroke:black_color,fill:default_color
    });

    if(isSign){
        svg.paper.text(x+30, y+5, "原有电缆(通道)").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 新建通道电缆
 */
function svg_new_passageway_wall(x,y,isSign){
    svg.paper.rect(x-30, y-5, 10, 10, 0).attr({
        stroke:black_color,fill:"none"
    });

    svg.paper.rect(x+20, y-5, 10, 10, 0).attr({
        stroke:black_color,fill:"none"
    });

    svg.paper.line(x-30,  y-5, x+20, y-5).attr({
        stroke:black_color,fill:default_color
    });

    svg.paper.line(x-30,  y+5, x+20, y+5).attr({
        stroke:black_color,fill:default_color
    });

    if(isSign){
        svg.paper.text(x+30, y+5, "新建电缆(通道)").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 原有电缆井
 * @param x
 * @param y
 * @param isSign
 */
function svg_old_cable_well(x,y,isSign){
    var r=15;
    svg.paper.circle(x,y, r).attr({
        fill:default_color,stroke:black_color
    });

    svg.paper.line(x-r,  y, x+r, y).attr({
        stroke:black_color,fill:default_color
    });

    svg.paper.line(x,  y-r, x, y+r).attr({
        stroke:black_color,fill:default_color
    });

    if(isSign){
        svg.paper.text(x+30, y+5, "原有电缆井").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 新建电缆井
 * @param x
 * @param y
 * @param isSign
 */
function svg_new_cable_well(x,y,isSign){
    var r=15;
    svg.paper.circle(x,y, r).attr({
        fill:"none",stroke:black_color
    });

    svg.paper.line(x-r,  y, x+r, y).attr({
        stroke:black_color,fill:default_color
    });

    svg.paper.line(x,  y-r, x, y+r).attr({
        stroke:black_color,fill:default_color
    });

    if(isSign){
        svg.paper.text(x+30, y+5, "新建电缆井").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 新建同杆点位
 * @param x
 * @param y
 * @param isSign
 */
function svg_new_point_one(x,y,isSign,height){
/*
        同杆假设点位图例绘制参考

        <circle cx="100" cy="100" r="100" fill="black" stroke="black"></circle>
        <polygon points="100,200 0,200 0,0 100,0 100,200" stroke="white" fill="white"></polygon>
        <circle cx="100" cy="100" r="100" fill="none" id="circle2" stroke="black"></circle>
*/

    var r=10;
    svg.paper.circle(x,y, r).attr({
        fill:default_color,stroke:default_color
    });
    svg.paper.polygon(x,y+r ,x-r,y+r ,x-r,y-r ,x,y-r, x,y+r).attr({
        fill:white_color,stroke:white_color
    });
    svg.paper.circle(x,y, r).attr({
        fill:"none",stroke:default_color
    });

    if(isSign){
        svg.paper.text(x+30, y+5, "同杆").attr({
            style:"font-size:10pt",fill:default_color
        });
    }else{
        if(height!=undefined){
            if(height.length==1){
                svg.paper.text(x-4,y+5, height);
            }else{
                svg.paper.text(x-8,y+5, height);
            }
        }
    }
}



/**
 * 搭火点
 */
function svg_catch_fire_point(x,y,isSign){
    var r=15;
    svg.paper.circle(x,y, r/2).attr({
        fill:default_color,stroke:black_color
    });
    svg.paper.circle(x,y, r).attr({
        fill:"none",stroke:black_color
    });

    if(isSign){
        svg.paper.text(x+30, y+5, "搭火点").attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 拉线标尺
 */
function svg_pull_rule(x,y){
    var h=30;
    svg.paper.line(x,  y-h/2, x, y+h/2).attr({
        stroke:black_color,fill:default_color
    });
    svg.paper.line(x-h/2, y+h/2, x+h/2, y+h/2).attr({
        stroke:black_color,fill:default_color
    });
    svg.paper.text(x+30, y+10, "拉线").attr({
        style:"font-size:10pt",fill:default_color
    });
}

/**
 * 矩形框中文字 户表箱 开关柜 配电室 电缆分支箱 环网柜
 */
function svg_rect_center_text(x,y,textName,textName2,isSign){
    svg.paper.rect(x-15, y-10, 20, 20, 0).attr({
        stroke:black_color,fill:white_color
    });
    svg.paper.text(x-13, y+4, textName).attr({
        style:"font-size:8pt",fill:default_color
    });
    if(isSign){
        svg.paper.text(x+30, y+5, textName2).attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 下户点
 * @param x
 * @param y
 * @param isSign
 * @param doorName 下户名称
 * @param doorNum 下户数
 */
function svg_next_door(x,y,isSign,doorName,doorNum,doorName2){
    var h=28;
    if(doorName != undefined && doorName!=null){
        h=doorName.length*14;
    }

    var h2=(doorNum+"").length*14;
    svg.paper.rect(x-30, y-15, h+5, 30, 0).attr({
        stroke:black_color,fill:white_color
    });
    svg.paper.rect(x+h-25, y-15, h2+4 , 30, 0).attr({
        stroke:black_color,fill:white_color
    });
    svg.paper.text(x-28, y+5, doorName).attr({
        style:"font-size:8pt",fill:default_color
    });
    var str = doorNum+"";
    svg.paper.text(x+h-22, y+5, str).attr({
        style:"font-size:8pt",fill:default_color
    });
    if(isSign){
        svg.paper.text(x+30+h+4 , y+5, doorName2).attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 特征点
 * @param x
 * @param y
 * @param isSign
 * @param thingName
 */
function svg_crossing_thing(x,y,isSign,thingName){
    if(isSign){//标尺
        var line1=svg.paper.line(x-30, y, x+10, y).attr({
            stroke:black_color,
            fill:default_color,
            //markerEnd:m2
        });
        var line2=svg.paper.line(x+72, y, x+32, y).attr({
            stroke:black_color,
            fill:default_color,
            //markerEnd:m2
        });
        svg.paper.polygon([x-10,y-5,x-10,y,x+10,y]).attr(
            {
                fill:black_color
            }
        );
        svg.paper.polygon([x+52,y-5,x+52,y,x+32,y]).attr(
            {
                fill:black_color
            }
        );
        svg.paper.text(x+84 , y+5, thingName).attr({
            style:"font-size:10pt",fill:default_color
        });
    }
}

/**
 * 加载单线图数据
 */
function load_svg_data(){
    var minLngNum=minLng(svgPoint);
    var maxLatNum=maxLat(svgPoint);
    //经纬度转平面坐标系
    var maxSvgWidth=0;
    var maxSvgHeight=0;
    //  点位坐标换算
    for(var i = 0; i < svgPoint.length; i++){
            //杆塔经纬度
        var lgt=svgPoint[i].lgt;
        var lat=svgPoint[i].lat;

        //  点位平面坐标
        svgPoint[i].x=(lgt-minLngNum)*zoomNum+svgRectWidth+wuchaData;//防止遮住点位
        svgPoint[i].y=(maxLatNum-lat)*zoomNum+wuchaData;//防止遮住点位

        //  拉线平面坐标
        if(svgPoint[i].pullNum != null && svgPoint[i].pullNum > 0){

            var uss = 0;
            for(var j=0;j<svgLaxian.length;j++){
                if(svgPoint[i].id==svgLaxian[j].pid){
                    var lgt_lx = svgLaxian[j].lgt;
                    var lat_lx = svgLaxian[j].lat;

                    //同一杆塔上有两条及以上的拉线时
                    if(uss != 0) {
                        if (svgPoint[i].pullNum > 1 ) {
                            svgPoint[i].morelxx = (lgt_lx - minLngNum) * zoomNum + svgRectWidth + wuchaData;//防止遮住点位
                            svgPoint[i].morelxy = (maxLatNum - lat_lx) * zoomNum + wuchaData;//防止遮住点位
                        }
                    }else{

                        //  只有一根拉线或第一根拉线时
                        svgPoint[i].nlxx=(lgt_lx-minLngNum)*zoomNum+svgRectWidth+wuchaData;//防止遮住点位
                        svgPoint[i].nlxy=(maxLatNum-lat_lx)*zoomNum+wuchaData;//防止遮住点位
                        ++uss;
                    }


                }

            }
        }

        //以下用于判断SVG宽度和高度用
        if(maxSvgWidth < svgPoint[i].x+50){
            maxSvgWidth = svgPoint[i].x+50;
        }
        if(maxSvgHeight < svgPoint[i].y+220){
            maxSvgHeight = svgPoint[i].y+220;
        }

    }

    if(maxSvgWidth>minSvgWidth){
        svgWidth=maxSvgWidth;
    }else{
        svgWidth=minSvgWidth;
    }

    if(maxSvgHeight>minSvgHeight){
        svgHeight=maxSvgHeight;
    }else{
        svgHeight=minSvgHeight;
    }
    svg.attr({width:svgWidth,height:svgHeight});
    //指北标志
    zhibei(svgWidth);
    //描点
    drawSvgPoint();
    //画定位点之间的线
    drawSvgLine();
    //画拉线
    drawPushLine();
    //填写描述
    drawDescribetion();
    //画右下角标尺
    drawSvgRemark();
}

//描点
function drawSvgPoint(){
    //描点
    for(var i = 0; i < svgPoint.length; i++){
        var pointObj=svgPoint[i];
        var x=pointObj.x;
        var y=pointObj.y;

        if(pointObj.type=="变压器"){//变压器
            svg_new_transformer(x,y,false);
            svg.paper.text(x, y-10, pointObj.code);
        }else if(pointObj.type=="杆塔" && (pointObj.isPole=="否" || pointObj.isPole == null)){//杆塔(非同杆)
            var poleHeight = pointObj.poleHeight.substring(0,pointObj.poleHeight.length-1);
            svg_new_poles(x, y, false, poleHeight);
            svg.paper.text(x, y-10, pointObj.code);
        }else if(pointObj.type=="杆塔" && pointObj.isPole=="是" ){//杆塔(同杆架设点位)
            var poleHeight = pointObj.poleHeight.substring(0,pointObj.poleHeight.length-1);
            // svg_new_poles(x, y, false, poleHeight);
            // svg_new_point_one(x,y,false,poleHeight);
            svg_tg_poles(x,y,false,poleHeight);
            svg.paper.text(x, y-10, pointObj.code);
        }else if(pointObj.type=="同杆架设" && pointObj.isPole=="是" ){//杆塔(同杆架设点位)
            var poleHeight = pointObj.poleHeight.substring(0,pointObj.poleHeight.length-1);
            // svg_new_poles(x, y, false, poleHeight);
            // svg_new_point_one(x,y,false,poleHeight);
            // svg_tg_poles(x,y,false,poleHeight);
            // svg.paper.text(x, y-10, pointObj.code);
        }else if(pointObj.type=="下户点"){//下户点
            // svg_next_door(x,y,false,pointObj.code,1,"下户点")
            svg_rect_center_text(x,y,"XH","下户点",false);
            svg.paper.text(x+8,y+5, pointObj.code);
        }else if(pointObj.type=="分支箱"){//电缆分支箱
            svg_rect_center_text(x,y,"FZ","分支箱",false);
            svg.paper.text(x+8,y+5, pointObj.code);
        }else if(pointObj.type == "表箱"){//表箱
            svg_rect_center_text(x,y,"HB","表箱",false);
            svg.paper.text(x+8,y+5, pointObj.code);
        }else if(pointObj.type == "电缆井"){//电缆井
            svg_new_cable_well(x,y,false);
            svg.paper.text(x, y - 10, pointObj.code);
        }else if(pointObj.type == "交叉跨越"){//跨越物
            // if(pointObj.next_exploration_id!=null&&pointObj.distance!=undefined){//跨越物没有下一级不画
                drawSvgCrossingThing(pointObj);
            // }
        }
    }
}

/**
 * 画跨域物
 * @param pointObj
 */
function drawSvgCrossingThing(pointObj){
    var beforePoint,lastPoint;//上一个点和下一个点对象
    for(var i = 0; i < svgCross.length; i++){
        var tempPoint=svgCross[i];
        //上一个定位点
        if(pointObj.id == tempPoint.upId){
            beforePoint=tempPoint;
        }
        //下一个定位点
        if(pointObj.id == tempPoint.lowerId){
            lastPoint=tempPoint;
        }
    }
    //相似三角形比率
    if(lastPoint!=undefined && lastPoint.span !=undefined && pointObj.span!=undefined){
        var ratio=lastPoint.span/pointObj.span;
        pointObj.x=(lastPoint.x-beforePoint.x)/ratio+beforePoint.x;
        pointObj.y=(lastPoint.y-beforePoint.y)/ratio+beforePoint.y;
        var x=pointObj.x;
        var y=pointObj.y;
        if(lastPoint.x == beforePoint.x){//x坐标相等的时候
            var line1=svg.paper.line(x-70, y, x-10, y).attr({
                stroke:black_color,
                fill:default_color,
            });
            var line2=svg.paper.line(x+10, y, x+70, y).attr({
                stroke:black_color,
                fill:default_color,
            });
            svg.paper.polygon([x-10,y,x-30,y,x-30,y-5]).attr({
                fill:black_color
            });
            svg.paper.polygon([x+10,y,x+30,y,x+30,y-5]).attr({
                fill:black_color
            });
            svg.paper.text(x+80 , y+5,pointObj.crossType).attr({
                style:"font-size:10pt",fill:default_color
            });
        }else if(lastPoint.y==beforePoint.y){//y坐标相等的时候
            var line1=svg.paper.line(x, y-70, x, y-10).attr({
                stroke:black_color,
                fill:default_color,
            });
            var line2=svg.paper.line(x, y+10, x, y+70).attr({
                stroke:black_color,
                fill:default_color,
            });
            svg.paper.polygon([x,y-10,x,y-30,x+5,y-30]).attr({
                fill:black_color
            });
            svg.paper.polygon([x,y+10,x,y+30,x+5,y+30]).attr({
                fill:black_color
            });
            svg.paper.text(x+5 , y+80, pointObj.crossType).attr({
                style:"font-size:10pt",fill:default_color
            });
        }else{
            var k=(lastPoint.y-beforePoint.y)/(lastPoint.x-beforePoint.x);
            var b=lastPoint.y-k*lastPoint.x;
            drawMarker(k,b,pointObj.x,pointObj.y,pointObj.crossType);
        }
    }
}

function getFeaturesName(pt_id){
    var fname="";
    switch(pt_id){
        case 100014:fname="植被";break;
        case 100015:fname="房屋";break;
        case 100016:fname="通讯线";break;
        case 100017:fname="低压线路";break;
        case 100018:fname="沟河流";break;
        case 100019:fname="道路";break;
        case 100020:fname="高压线路";break;
        default :"";
    }
    return fname;
}

/**
 * 在一条直线上画出带箭头的跨越物
 * @param k
 * @param b
 * @param x
 * @param y
 * @param fname 跨越物名称
 */
function drawMarker(k,b,x,y,fname){
    var h1=10;
    var h2=30;
    var h3=50;
    var h4=5;
    var k2=-1/k;
    var b2=y-k2*x;
    var point1=getPointBykbAndDistance(k2,b2,h1,x,y);
    var point2=getPointBykbAndDistance(k2,b2,h2,x,y);
    var point3=getPointBykbAndDistance(k2,b2,h3,x,y);

    //明天任务 划线 跨越物名称筛选
    var line1=svg.paper.line(point1.x1,point1.y1, point3.x1,point3.y1).attr({
        stroke:black_color,
        fill:default_color,
    });
    var line2=svg.paper.line(point1.x2,point1.y2, point3.x2,point3.y2).attr({
        stroke:black_color,
        fill:default_color,
    });
    var b4=point2.y1-k*point2.x1;
    var point4=getPointBykbAndDistance(k,b4,h4,point2.x1,point2.y1);
    svg.paper.polygon([point1.x1,point1.y1,point2.x1,point2.y1,point4.x1,point4.y1]).attr({
        fill:black_color
    });
    var b5=point2.y2-k*point2.x2;
    var point5=getPointBykbAndDistance(k,b5,h4,point2.x2,point2.y2);
    svg.paper.polygon([point1.x2,point1.y2,point2.x2,point2.y2,point5.x1,point5.y1]).attr({
        fill:black_color
    });

    svg.paper.text(point3.x1, point3.y1, fname).attr({
        style:"font-size:10pt",fill:default_color
    });
}

/**
 * 画定位点之间的连线线
 */
function drawSvgLine(){
    for(var i = 0; i < svgPoint.length; i++){
        // if(svgPoint[i].pt_id<100014){
            for(var j = 0; j < svgPoint.length; j++){
                if(svgPoint[i].id==svgPoint[j].upId){
                    var x1=svgPoint[i].x;
                    var y1=svgPoint[i].y;
                    var x2=svgPoint[j].x;
                    var y2=svgPoint[j].y;
                    var xlName = svgPoint[j].lineName;

                    if(svgPoint[j].voltage=="10kv"){//10kv
                        svg_new_10kv_lines(x1,y1,x2,y2,false);
                    }else if(svgPoint[j].voltage=="400v"){//0.38kv
                        svg_new_38_lines(x1,y1,x2,y2,false);
                    }else if(svgPoint[j].voltage=="220v"){//0.22kv
                        svg_new_22_lines(x1,y1,x2,y2,false);
                    }
                    //档距--要求保留2位小数
                    if(svgPoint[j].type == "杆塔"){
                        var sp = svgPoint[j].span;
                        // drawTextByLine(svgPoint[i].x, svgPoint[i].y, svgPoint[j].x, svgPoint[j].y,Math.ceil(svgPoint[j].span).toFixed(2));
                        drawTextByLine(svgPoint[i].x, svgPoint[i].y, svgPoint[j].x, svgPoint[j].y,sp.toFixed(2));
                    }else if(svgPoint[j].type == "表箱"){
                        var ins = svgPoint[j].inletLine;
                        // drawTextByLine(svgPoint[i].x, svgPoint[i].y, svgPoint[j].x, svgPoint[j].y,Math.ceil(svgPoint[j].inletLine).toFixed(2));
                        drawTextByLine(svgPoint[i].x, svgPoint[i].y, svgPoint[j].x, svgPoint[j].y,ins.toFixed(2));
                    }

                    //  线路名称显示
                    if(svgPoint[j].type == "杆塔"){
                        console.log("线路名称显示=="+j+">>>"+xlName)
                        drawTextByLineName(svgPoint[i].x, svgPoint[i].y, svgPoint[j].x, svgPoint[j].y,xlName);
                    }


                }
            }
        // }

    }
}


//在线上方H处显示文字
function drawTextByLine(ax1,ay1,ax2,ay2,text){
    //在线上放H处显示文字
    var h=10;
    if(ax2!=ax1 && ay2!=ay1){
        var k=(-1)/((ay2-ay1)/(ax2-ax1));//算斜率
        var x1=(ax1+ax2)/2;
        var y1=(ay1+ay2)/2;
        var b=y1-k*x1;
        var ta=(h*h-x1*x1-(b-y1)*(b-y1))/(1+k*k);
        var tb=(k*b-k*y1-x1)/(1+k*k);
        var x2=Math.sqrt(ta+tb*tb)-tb;
        var y2=k*x2+b;
        svg.paper.text(x2, y2, text);
    }else{
        if(ax2==ax1){
            svg.paper.text(ax1+h, (ay2+ay1)/2, text);
        }else if(ay2==ay1){
            svg.paper.text((ax1+ax2)/2, ay1-h, text);
        }
    }

}

/**
 *  线路名称显示
 *
 * @param ax1
 * @param ay1
 * @param ax2
 * @param ay2
 * @param text
 */
function drawTextByLineName(ax1,ay1,ax2,ay2,text){
    //在线上放H处显示文字
    var h=10;
    if(ax2!=ax1 && ay2!=ay1){
        var k=(-1)/((ay2-ay1)/(ax2-ax1));//算斜率
        var x1=(ax1+ax2)/2;
        var y1=(ay1+ay2)/2;
        //  一半的一半
        var xN1 = (x1+ax2)/2;
        var yN1 = (y1+ay2)/2;

        var b=yN1-k*xN1;
        var ta=(h*h-xN1*xN1-(b-yN1)*(b-yN1))/(1+k*k);
        var tb=(k*b-k*yN1-xN1)/(1+k*k);
        var x2=Math.sqrt(ta+tb*tb)-tb;
        var y2=k*x2+b;
        svg.paper.text(x2, y2, text);
    }else{
        if(ax2==ax1){
            svg.paper.text(ax1+h, (ay2+ay1)/3, text);
        }else if(ay2==ay1){
            svg.paper.text((ax1+ax2)/3, ay1-h, text);
        }
    }

}

//获取最小的经度
function minLng(data){
    var temp=180;
    for(var i = 0; i < data.length; i++){
        var lng=data[i].lgt;
        if(lng!= null && temp > lng){
            temp=lng;
        }
    }
    return temp
}
//获取最大维度
function maxLat(data){
    var temp=0;
    for(var i = 0; i < data.length; i++){
        var lat=data[i].lat;
        if(lat!=null && temp < lat){
            temp=lat;
        }
    }
    return temp
}
/**
 * 放大
 */
function svg_enlarge(){
    svg.clear();
    zoomNum=zoomNum*2;
    init_load(byqId,byqName);
    //load_svg_data();
}
/**
 * 缩小
 */
function svg_narrow(){
    svg.clear();
    zoomNum=zoomNum/2;
    init_load(byqId,byqName);
    //load_svg_data();
}

/**
 * 画拉线
 * @Time 2018-8-6 16:26:14
 */
function drawPushLine(){

    //选出所有塔杆
    var poleArr=new Array();
    for(var i = 0; i < svgPoint.length; i++){
        if(svgPoint[i].type=="杆塔" && svgPoint[i].pullNum > 0){//是塔杆且转角不为0,且材料小类有拉线
            poleArr.push(svgPoint[i]);
        }
    }


    for(var i=0;i<poleArr.length;i++){
        var children = new Array();
        for(var j=0;j<svgLaxian.length;j++){
            if(poleArr[i].id==svgLaxian[j].pid){
                children.push(svgLaxian[j]);
            }
        }
        poleArr[i].children=children;
    }

    //甄别到底是一个塔杆还是2个还是2个以上，分别画拉线
    for(var i=0;i<poleArr.length;i++){
        var cNum=poleArr[i].children.length;
        var x1=poleArr[i].x;
        var y1=poleArr[i].y;
        var x2=poleArr[i].nlxx;
        var y2=poleArr[i].nlxy;
        var x3=poleArr[i].morelxx;
        var y3=poleArr[i].morelxy;

        if(cNum = 1){
            drawLineTwoPoint(x1,y1,x2,y2);
        }else{
            drawLineNozero2(x1,y1,x2,y2);
        }

        //同一杆塔上有多条拉线时
        if(poleArr[i].pullNum > 1) {
            drawLineTwoPoint(x1,y1,x3,y3);
        }
    }
}
//画拉线
/*function drawPushLine(){
 //选出所有塔杆
 var poleArr=new Array();
 for(var i = 0; i < svgData.length; i++){
 //console.log(svgData[i].number,svgData[i].pt_id, svgData[i].corner,svgData[i].pushLines);
 if(svgData[i].pt_id==100004 && svgData[i].pushLines > 0){//是塔杆且转角不为0,且材料小类有拉线
 poleArr.push(svgData[i]);
 //画拉线数量
 if(svgData[i].pushLines > 1) {
 svg.paper.text(svgData[i].x-15 , svgData[i].y+25, "【" + svgData[i].pushLines+"】" ).attr({
 style: "font-size:10pt", fill: default_color
 });
 }

 }
 }
 //查出所有塔杆的上级和下级
 for(var i=0;i<poleArr.length;i++){
 var children = new Array();
 for(var j=0;j<svgData.length;j++){
 if((poleArr[i].before_exp==svgData[j].exploration_id
 ||poleArr[i].exploration_id==svgData[j].before_exp) && svgData[j].pt_id<100014){
 children.push(svgData[j]);
 }
 }
 poleArr[i].children=children;
 }
 //甄别到底是一个塔杆还是2个还是2个以上，分别画拉线
 for(var i=0;i<poleArr.length;i++){
 var cNum=poleArr[i].children.length;
 if(cNum==0){//0个垂直
 svg.paper.line(poleArr[i].x, poleArr[i].y, poleArr[i].x,poleArr[i].y+20).attr({
 stroke: default_color,
 strokeWidth: 2
 });
 svg.paper.line(poleArr[i].x-10, poleArr[i].y+20, poleArr[i].x+10,poleArr[i].y+20).attr({
 stroke: default_color,
 strokeWidth: 2
 });
 }else if(cNum==1){//1个垂直，延长线上
 var x1=poleArr[i].x;
 var y1=poleArr[i].y;
 var x2=poleArr[i].children[0].x;
 var y2=poleArr[i].children[0].y;

 drawLineTwoPoint(x1,y1,x2,y2);
 }else{//2个以上在最少的那个方向
 //点分组
 //四象限
 var xiangxian=[
 {"key":"++","value":0},
 {"key":"+-","value":0},
 {"key":"--","value":0},
 {"key":"-+","value":0}
 ];
 var x1=poleArr[i].x;
 var y1=poleArr[i].y;
 var children=poleArr[i].children;
 for(var j=0;j<children.length;j++){
 var x2=children[j].x;
 var y2=children[j].y;
 var tx=x2-x1;
 var ty=y2-y1;
 if(tx>=0 && ty>0){//++
 xiangxian[0].value++;
 }else if(tx>0 && ty<=0){//+-
 xiangxian[1].value++;
 }else if(tx<=0 && ty<0){//--
 xiangxian[2].value++;
 }else if(tx<0 && ty>=0){//-+
 xiangxian[3].value++;
 }
 }
 //得到最小象限
 var temp=xiangxian.length;
 var txx=0;
 for(var j=0;j<xiangxian.length;j++){
 if(temp > xiangxian[j].value){
 temp=xiangxian[j].value;
 txx=j;
 }
 }

 //++ -- 斜率为1
 var h=20;//延长线距离
 if("++" === xiangxian[txx].key){
 var k=1;
 var b=y1-k*x1;
 var x2=Math.sqrt(2)*h/2+x1;
 var y2=Math.sqrt(2)*h/2+y1;
 drawLineNozero2(k,x1,y1,x2,y2);
 }else if("--"==xiangxian[txx].key){
 var k=-1;
 var b=y1-k*x1;
 var x2=x1-Math.sqrt(2)*h/2;
 var y2=y1-Math.sqrt(2)*h/2;
 drawLineNozero2(k,x1,y1,x2,y2);
 }else if("+-" === xiangxian[txx].key){//+- -+ 斜率为-1
 var k=-1;
 var b=y1+x1;
 var x2=Math.sqrt(2)*h/2+x1;
 var y2=y1-Math.sqrt(2)*h/2;
 drawLineNozero2(k,x1,y1,x2,y2);
 }else if("-+"==xiangxian[txx].key ){
 var x2=x1-Math.sqrt(2)*h/2;
 var y2=Math.sqrt(2)*h/2+y1;
 drawLineNozero2(k,x1,y1,x2,y2);
 }
 }
 }
 }*/

//画拉线,2个点的时候，包括平行X和Y的情况
function drawLineTwoPoint(x1,y1,x2,y2){
    if(x1!=x2 && y1!=y2){
        drawLineNozero(x1,y1,x2,y2);
    }else{
        drawLineZero(x1,y1,x2,y2);
    }
}
/**
 * 杆塔无下联时的拉线位置
 * @param x1
 * @param y1
 * @param x2
 * @param y2
 * @Time 2018-8-6 16:18:05
 */
//画拉线,2个点的时候,延长线斜率不为0的情况【开始画横竖拉线】
function drawLineNozero(x1,y1,x2,y2){
    var k=(y1-y2)/(x1-x2);
    var b=y1-k*x1;
    var h=1;//延长线距离
    //勾股定理+直线坐标公式
    //(x-x1)^2+(y-y1)^2=h^2
    //y=kx+b
    /* var ta=(h*h-x2*x2-(b-y2)*(b-y2))/(1+k*k);
     var tb=(k*b-k*y2-x2)/(1+k*k);
     // alertTip("ta="+ta+","+tb);
     var laxx=Math.sqrt(ta+tb*tb)-tb;
     if((laxx>x1 && laxx<x2)||(laxx<x1 && laxx>x2)){//如果正值在线段内，则取负值
     laxx=-Math.sqrt(ta+tb*tb)-tb;
     }
     var laxy=k*laxx+b;*/
    // alertTip("第一线="+x1+","+y1+","+x2+","+y2);
    //第一条线
    svg.paper.line(x1, y1, x2,y2).attr({
        stroke: default_color,
        strokeWidth: 2
    });
    //第二条线
    var laxk=-1/k;
    var laxb=y2-laxk*x2;
    var h2=10;//垂直线的一半
    //勾股定理+直线坐标公式
    //(x-x1)^2+(y-y1)^2=h^2
    //y=kx+b
    var ta2=(h2*h2-x2*x2-(laxb-y2)*(laxb-y2))/(1+laxk*laxk);
    var tb2=(laxk*laxb-laxk*y2-x2)/(1+laxk*laxk);
    //垂直线的第一个点根据公式计算出来
    var laxx1=Math.sqrt(ta2+tb2*tb2)-tb2;
    var laxy1=laxk*laxx1+laxb;
    var laxx2=x2+(x2-laxx1);
    var laxy2=laxk*laxx2+laxb;
    // alertTip("第二线="+laxx1+","+laxy1+","+laxx2+","+laxy2);
    svg.paper.line(laxx1, laxy1, laxx2,laxy2).attr({
        stroke: default_color,
        strokeWidth: 2
    });
}
/*function drawLineNozero(x1,y1,x2,y2){
 var k=(y1-y2)/(x1-x2);
 var b=y1-k*x1;
 var h=20;//延长线距离
 //勾股定理+直线坐标公式
 //(x-x1)^2+(y-y1)^2=h^2
 //y=kx+b
 var ta=(h*h-x1*x1-(b-y1)*(b-y1))/(1+k*k);
 var tb=(k*b-k*y1-x1)/(1+k*k);
 alertTip("ta="+ta+","+tb);
 var laxx=Math.sqrt(ta+tb*tb)-tb;
 if((laxx>x1 && laxx<x2)||(laxx<x1 && laxx>x2)){//如果正值在线段内，则取负值
 laxx=-Math.sqrt(ta+tb*tb)-tb;
 }
 var laxy=k*laxx+b;
 // alertTip("laxx="+x1+","+y1+","+laxx+","+laxy);
 //第一条线
 svg.paper.line(x1, y1, laxx,laxy).attr({
 stroke: default_color,
 strokeWidth: 2
 });
 //第二条线
 var laxk=-1/k;
 var laxb=laxy-laxk*laxx;
 var h2=10;//垂直线的一半
 //勾股定理+直线坐标公式
 //(x-x1)^2+(y-y1)^2=h^2
 //y=kx+b
 var ta2=(h2*h2-laxx*laxx-(laxb-laxy)*(laxb-laxy))/(1+laxk*laxk);
 var tb2=(laxk*laxb-laxk*laxy-laxx)/(1+laxk*laxk);
 //垂直线的第一个点根据公式计算出来
 var laxx1=Math.sqrt(ta2+tb2*tb2)-tb2;
 var laxy1=laxk*laxx1+laxb;
 var laxx2=laxx+(laxx-laxx1);
 var laxy2=laxk*laxx2+laxb;
 svg.paper.line(laxx1, laxy1, laxx2,laxy2).attr({
 stroke: default_color,
 strokeWidth: 2
 });
 }*/
//斜率为0的情况
function drawLineZero(x1,y1,x2,y2){
    if(x1==x2){
        svg.paper.line(x1, y1, x1,y1+20).attr({
            stroke: default_color,
            strokeWidth: 2
        });

        svg.paper.line(x1-10, y1+20, x1+10,y1+20).attr({
            stroke: default_color,
            strokeWidth: 2
        });
    }else if(y1==y2){
        svg.paper.line(x1, y1, x1+20,y1).attr({
            stroke: default_color,
            strokeWidth: 2
        });
        svg.paper.line(x1+20, y1-10, x1+20,y1+10).attr({
            stroke: default_color,
            strokeWidth: 2
        });
    }

}
//画拉线,两个点以上的时候,四象限画拉线用
//象限点数最少的45度画拉线
function drawLineNozero2(x1,y1,x2,y2){
    var k=(y1-y2)/(x1-x2);
    var laxx=x2;
    var laxy=y2;
    //第一条线
    svg.paper.line(x1, y1, laxx,laxy).attr({
        stroke: default_color,
        strokeWidth: 2
    });
    //第二条线
    var laxk=-1/k;
    var laxb=laxy-laxk*laxx;
    var h2=10;//垂直线的一半
    //勾股定理+直线坐标公式
    //(x-x1)^2+(y-y1)^2=h^2
    //y=kx+b
    var ta2=(h2*h2-laxx*laxx-(laxb-laxy)*(laxb-laxy))/(1+laxk*laxk);
    var tb2=(laxk*laxb-laxk*laxy-laxx)/(1+laxk*laxk);
    //垂直线的第一个点根据公式计算出来
    var laxx1=Math.sqrt(ta2+tb2*tb2)-tb2;
    var laxy1=laxk*laxx1+laxb;
    var laxx2=laxx+(laxx-laxx1);
    var laxy2=laxk*laxx2+laxb;
    svg.paper.line(laxx1, laxy1, laxx2,laxy2).attr({
        stroke: default_color,
        strokeWidth: 2
    });
}
//是否为中文
function isChinese(temp)
{
    var reg=/[\u4E00-\u9FA5\uF900-\uFA2D]/;
    if (!reg.test(temp)){
        return false ;
    } else {
        return true ;
    }
}
//获取描述行数
function getHangNum(){
    var ziSize=400;//长度超过400换行
    var tempPx=0;
    var arr = svgSpec;
    var n=0;
    for(var i=0;i<arr.length;i++){
        var str = arr.substring(i,i+1);
        if(isChinese(str)){
            tempPx+=12;
        }else{
            tempPx+=8;
        }
        if(str=="。"){
            n++;tempPx=0;
        }else{
            if(tempPx > ziSize){
                n++;tempPx=0;
            }
        }

    }
    return n;
}

/**
 * 单线图描述
 */
function drawDescribetion(){
    var ziSize=400;//长度超过400换行
    // var arr = svgSpec.split("。");
    var arr = svgSpec;
    var n=getHangNum();
    var tempStr="";
    var tempPx = 0;
    for(var i=0;i<arr.length;i++){
        var str = arr.substring(i,i+1);
        tempStr+=str;
        if(isChinese(str)){
            tempPx+=12;
        }else{
            tempPx+=8;
        }
        if(str=="。"){
            svg.paper.text(30, svgHeight - 30*n-10, tempStr).attr({
                style:"font-size:10pt",fill:default_color
            });
            tempStr="";
            tempPx=0;
            n--;
        }else{
            if(tempPx > ziSize){
                svg.paper.text(30, svgHeight - 30*n-10, tempStr).attr({
                    style:"font-size:10pt",fill:default_color
                });
                tempStr="";
                tempPx=0;
                n--;
            }else if((i+1)==arr.length){
                svg.paper.text(30, svgHeight - 30*n-10, tempStr).attr({
                    style:"font-size:10pt",fill:default_color
                });
                tempStr="";
                tempPx=0;
                n--;
            }
        }
    }
}

//右下角矩形框长度和宽度
var rightBottomRectWidth=550;
var rightBottomRectHeight=200;
var fontSize="font-size:5pt";
/**
 * 右下角矩形框
 * @param svg
 */
function drawSvgRemark(){
    var textSizePx=12;
    //矢量图边框
    svg.paper.rect(0, 0, svgWidth, svgHeight, 0).attr({
        stroke:"rgb(0,0,0)",
        fill:"none",
        strokeWidth:"5",
    });

    //右下角矩形框
    var r2w=svgWidth-rightBottomRectWidth;
    var r2h=svgHeight-rightBottomRectHeight;
    svg.paper.rect(r2w, r2h, rightBottomRectWidth, rightBottomRectHeight, 0).attr({
        stroke:"rgb(0,0,0)",
        fill:"none",
        strokeWidth:"2",
    });
    var hanw=rightBottomRectWidth/12;
    var hanh=rightBottomRectHeight/5;
    //第一行
    svg.paper.line(r2w, r2h+hanh*1, svgWidth,r2h+hanh*1).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第一行 设计单位
    if(textsjdw != undefined && textsjdw!=''){
        var x1 = r2w+hanw*3-(textsjdw.length*textSizePx)/2;
        svg.paper.text(x1, r2h+hanh*0.6, textsjdw).attr({
            style:fontSize,fill:"rgb(0,0,0)"
        });
    }
    //第一行 第1根竖线
    svg.paper.line(r2w+hanw*6, r2h, r2w+hanw*6,r2h+hanh*1).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第一行 第2根竖线
    svg.paper.line(r2w+hanw*10, r2h, r2w+hanw*10,r2h+hanh*1).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });

    //第一行 汉字2
    var text2=projectName;
    var x2 = r2w+hanw*8-(text2.length*textSizePx)/2;
    svg.paper.text(x2, r2h+hanh*0.6, text2).attr({
        style:fontSize,fill:"rgb(0,0,0)"
    });

    //第一行 汉字3
    var text3=stageName;
    var x2 = r2w+hanw*11-(text3.length*textSizePx)/2;
    svg.paper.text(x2, r2h+hanh*0.6, text3).attr({
        style:fontSize,fill:"rgb(0,0,0)"
    });

    //第二行
    svg.paper.line(r2w, r2h+hanh*2, r2w+hanw*3,r2h+hanh*2).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    svg.paper.line(r2w+hanw*4, r2h+hanh*2, r2w+hanw*6,r2h+hanh*2).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第二行 第1根竖线
    svg.paper.line(r2w+hanw*1, r2h+hanh*1, r2w+hanw*1,r2h+hanh*2).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第二行 第2根竖线
    svg.paper.line(r2w+hanw*3, r2h+hanh*1, r2w+hanw*3,r2h+hanh*2).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //汉字
    var textpz="批准";
    var pzx = r2w+hanw*0.5-(textpz.length*textSizePx)/2;
    svg.paper.text(pzx, r2h+hanh*1.6, textpz).attr({
        style:fontSize,fill:"rgb(0,0,0)"
    });

    var textxh="校核";
    var xhx = r2w+hanw*3.5-(textxh.length*textSizePx)/2;
    svg.paper.text(xhx, r2h+hanh*2.1, textxh).attr({
        style:fontSize,fill:"rgb(0,0,0)"
    });
    //工程名称
    // var textgcmc="工程名称";
    textgcmc=textgcmc+" 示意图";
    if(textgcmc!=undefined && textgcmc!=''){
        var gcmcx = r2w+hanw*9-(textgcmc.length*textSizePx)/2;
        svg.paper.text(gcmcx, r2h+hanh*2.6, textgcmc).attr({
            style:fontSize,fill:"rgb(0,0,0)"
        });
    }
    //第二行 第3根竖线
    svg.paper.line(r2w+hanw*4, r2h+hanh*1, r2w+hanw*4,r2h+hanh*2).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    var textsh="审核";
    var shx = r2w+hanw*0.5-(textsh.length*textSizePx)/2;
    svg.paper.text(shx, r2h+hanh*3.1, textsh).attr({
        style:fontSize,fill:"rgb(0,0,0)"
    });
    //第二行 第4根竖线
    svg.paper.line(r2w+hanw*6, r2h+hanh*1, r2w+hanw*6,r2h+hanh*2).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第三行
    svg.paper.line(r2w+hanw*1, r2h+hanh*3, r2w+hanw*6,r2h+hanh*3).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第三行 第1根竖线
    svg.paper.line(r2w+hanw*1, r2h+hanh*2, r2w+hanw*1,r2h+hanh*3).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第三行 第2根竖线
    svg.paper.line(r2w+hanw*3, r2h+hanh*2, r2w+hanw*3,r2h+hanh*3).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第三行 第3根竖线
    svg.paper.line(r2w+hanw*4, r2h+hanh*2, r2w+hanw*4,r2h+hanh*3).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第三行 第4根竖线
    svg.paper.line(r2w+hanw*6, r2h+hanh*2, r2w+hanw*6,r2h+hanh*3).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第四行
    svg.paper.line(r2w, r2h+hanh*4, svgWidth,r2h+hanh*4).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第四行 第1根竖线
    svg.paper.line(r2w+hanw*1, r2h+hanh*3, r2w+hanw*1,r2h+hanh*4).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第四行 第2根竖线
    svg.paper.line(r2w+hanw*3, r2h+hanh*3, r2w+hanw*3,r2h+hanh*4).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //汉字
    var textsj="设计";
    var sjx = r2w+hanw*3.5-(textsj.length*textSizePx)/2;
    svg.paper.text(sjx, r2h+hanh*3.6, textsj).attr({
        style:fontSize,fill:"rgb(0,0,0)"
    });
    //第四行 第3根竖线
    svg.paper.line(r2w+hanw*4, r2h+hanh*3, r2w+hanw*4,r2h+hanh*4).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第四行 第4根竖线
    svg.paper.line(r2w+hanw*6, r2h+hanh*3, r2w+hanw*6,r2h+hanh*4).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第五行
    //第五行 第1根竖线
    svg.paper.line(r2w+hanw*1, r2h+hanh*4, r2w+hanw*1,r2h+hanh*5).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第五行 第2根竖线
    svg.paper.line(r2w+hanw*3, r2h+hanh*4, r2w+hanw*3,r2h+hanh*5).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第五行 第3根竖线
    svg.paper.line(r2w+hanw*4, r2h+hanh*4, r2w+hanw*4,r2h+hanh*5).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第五行 第4根竖线
    svg.paper.line(r2w+hanw*6, r2h+hanh*4, r2w+hanw*6,r2h+hanh*5).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第五行 第5根竖线
    svg.paper.line(r2w+hanw*7, r2h+hanh*4, r2w+hanw*7,r2h+hanh*5).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第五行 第6根竖线
    svg.paper.line(r2w+hanw*10, r2h+hanh*4, r2w+hanw*10,r2h+hanh*5).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第五行 第7根竖线
    svg.paper.line(r2w+hanw*11, r2h+hanh*4, r2w+hanw*11,r2h+hanh*5).attr({
        stroke: "rgb(0,0,0)",
        strokeWidth: 2
    });
    //第五行 汉字
    var textrh="日期";
    var brh = r2w+hanw*0.5-(textrh.length*textSizePx)/2;
    svg.paper.text(brh, r2h+hanh*4.6, textrh).attr({
        style:fontSize,fill:"rgb(0,0,0)"
    });

    var textbl="比列";
    var blx = r2w+hanw*3.5-(textbl.length*textSizePx)/2;
    svg.paper.text(blx, r2h+hanh*4.6, textbl).attr({
        style:fontSize,fill:"rgb(0,0,0)"
    });

    var textth="图号";
    var bth = r2w+hanw*6.5-(textth.length*textSizePx)/2;
    svg.paper.text(bth, r2h+hanh*4.6, textth).attr({
        style:fontSize,fill:"rgb(0,0,0)"
    });

    var textbc="版次";
    var bcx = r2w+hanw*10.5-(textbc.length*textSizePx)/2;
    svg.paper.text(bcx, r2h+hanh*4.6, textbc).attr({
        style:fontSize,fill:"rgb(0,0,0)"
    });


    /**
     * 将经纬度转换为平面坐标
     * @param lon
     * @param lat
     * @returns {{x: number, y: number}}
     * @Time 2018-8-6 09:38:17
     */
        // lon 经度，西经为负数
        // lat 纬度，南纬是负数

    /*var lat1=svgData[i].acableLat;
    var lng1=svgData[i].acableLng;

    function millerXY (lon1, lat1){
        var L = 6381372 * Math.PI * 2,     // 地球周长
            W = L, // 平面展开后，x轴等于周长
            H = L / 2, // y轴约等于周长一半
            mill = 2.3, // 米勒投影中的一个常数，范围大约在正负2.3之间
            x = lngLat.lng * Math.PI / 180, // 将经度从度数转换为弧度
            y = lngLat.lat * Math.PI / 180; // 将纬度从度数转换为弧度
        // 这里是米勒投影的转换
        y = 1.25 * Math.log( Math.tan( 0.25 * Math.PI + 0.4 * y ) );
        // 这里将弧度转为实际距离
        x = ( W / 2 ) + ( W / (2 * Math.PI) ) * x;
        y = ( H / 2 ) - ( H / ( 2 * mill ) ) * y;
        // alertTip("x="+x+";"+"y="+y);
        // 转换结果的单位是公里
        // 可以根据此结果，算出在某个尺寸的画布上，各个点的坐标
        return {
            x : x,
            y : y
        };
    }*/


}